package com.example.windswing;

public class WindSwingCommand {
    public static String MOTO_POSITIVE = "P";
    public static String MOTO_NEGATIVE = "N";
    public static String MOTO_STOP = "S";
    private OnSendCallback onSendCallback;

    public WindSwingCommand(){

    }

    public WindSwingCommand(OnSendCallback onSendCallback){
        this.onSendCallback = onSendCallback;
    }

    public void setOnSendCallback(OnSendCallback onSendCallback) {
        this.onSendCallback = onSendCallback;
    }

    public interface OnSendCallback{
        void onSend(String data);
    }

    /**
     * reset the wind swing [CS]
     */
    public void reset(){
        if(onSendCallback != null){
            onSendCallback.onSend("CS");
        }
    }

    /**
     * CAP1
     * @param motoIndex
     * @param state
     */
    public void singleMotoCtrl(int motoIndex, String state){
        if(onSendCallback != null){
            onSendCallback.onSend("CA" + state + motoIndex);
        }
    }

    /**
     * CBO left right swing freely
     */
    public void leftRightSwing(){
        if(onSendCallback != null){
            onSendCallback.onSend("CBO");
        }
    }

    /**
     * CC30 swing with angle
     * @param angle
     */
    public void swing(int angle){
        if(onSendCallback != null){
            onSendCallback.onSend("CC" + angle);
        }
    }

    /**
     * CD stop
     */
    public void stop(){
        if(onSendCallback != null){
            onSendCallback.onSend("CD");
        }
    }

    /**
     * CE circle
     * @param radium
     */
    public void circle(int radium){
        if(onSendCallback != null){
            onSendCallback.onSend("CE" + radium);
        }
    }

}
